<?php
        $theme2List = mysql_query("SELECT t.tag, MONTH(s.selectiondate) as month from theme t, selection s where t.tagID = s.themeId and selectiondate BETWEEN '2011-01-01' AND '2011-12-31' order by selectiondate asc")  or die("Anfrage fehlgeschlagen: " . mysql_error());
	$cnt2 = mysql_num_rows($theme2List);
?>
<h3>Selected Themes 2011:</h3>
<div id="year">
</div>
<br><br>
   <div id="themes" style="height: 500px;">
</div>

<script type="text/javascript">
    dojo.require("dijit.form.Button");
    dojo.require("dijit.Menu");
    dojo.addOnLoad(function() {
        var menu = new dijit.Menu({
            style: "display: none;"
        });
        var menuItem1 = new dijit.MenuItem({
            label: "2009",
            onClick: function() {
                alert('hi');
            }
        });
        menu.addChild(menuItem1);

        var menuItem2 = new dijit.MenuItem({
            label: "2010",
            onClick: function() {
                alert('ho');
            }
        });
        menu.addChild(menuItem2);
        
         var menuItem3= new dijit.MenuItem({
            label: "2011",
            onClick: function() {
                alert('ho');
            }
        });
        menu.addChild(menuItem3);

        var button = new dijit.form.ComboButton({
            label: "show year",
            dropDown: menu
        });
        dojo.byId("year").appendChild(button.domNode);
    });
</script>




   <script type="text/javascript">
        dojo.require("dojox.grid.DataGrid");
        dojo.require("dojo.data.ItemFileReadStore");

        dojo.addOnLoad(function() {
            // our test data store for this example:
             var storethemes ={
  identifier: 'month',
  label: 'month',
  items: [
<?php
function writeRow($month, $theme){
   $monthname = "";
   if($month == 1){
          $monthname = "January";
   }
   elseif($month == 2){
          $monthname = "February";
   }
   elseif($month == 3){
          $monthname = "March";
   }
   elseif($month == 4){
          $monthname = "April";
   }
   elseif($month == 5){
          $monthname = "May";
   }
   elseif($month == 6){
          $monthname = "June";
   }
   elseif($month == 7){
          $monthname = "July";
   }
   elseif($month == 8){
          $monthname = "August";
   }
   elseif($month == 9){
          $monthname = "September";
   }
   elseif($month == 10){
          $monthname = "October";
   }
   elseif($month == 11){
          $monthname = "November";
   }
   else{
          $monthname = "December";
   }
          
   echo "{ month:'".$monthname."', theme:'".$theme."'}";
   if($month <12){
         echo ",";
   }
} 


        $i = 1;
        while ($row = mysql_fetch_assoc($theme2List)) {
            if($row['month'] == $i){
                 writeRow($row['month'], $row['tag']);
            }
            else{
                  while($i<$month){
                      writeRow($i, "-");
                       $i++;
                  }
            }
            $i++;
        }
        while($i<=12){
                      writeRow($i, "-");
                       $i++;
                  }
?>
  ]
}  ;          
            var themeStore = new dojo.data.ItemFileReadStore({data: storethemes});


            // set the layout structure:
            var layoutthemes= [{
                field: 'month',
                name: 'Month',
                width: '100px'
            },
            {
                field: 'theme',
                name: 'Theme',
                width: 'auto'
            }
            ];

            // create a new grid:
            var gridthemes = new dojox.grid.DataGrid({
                query: {
                    month: '*'
                },
                store: themeStore,
                clientSort: true,
                rowSelector: '20px',
                structure: layoutthemes
            },
            document.createElement('div'));

            // append the new grid to the div "gridContainer4":
            dojo.byId("themes").appendChild(gridthemes.domNode);

            // Call startup, in order to render the grid:
            gridthemes.startup();
        });
    </script>



